<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>创建类和实例化对象</title>
</head>

<body>
  <script>
    class Star {
      // constructor 中放属性
      // 注意 constructor 不加function关键字
      constructor(uname, age, sex) {
        this.uname = uname;  //this指向实例化对象
        this.age = age;
        this.sex = sex;
      }
    }

    // 实例化对象
    var ldh = new Star('刘德华', '18', '男');

    console.log(ldh);
  </script>
</body>

</html>